import 'package:app_30/models/detail_entity.dart';
import 'package:app_30/models/img_entity.dart';
import 'package:app_30/models/load_entity.dart';
import 'package:app_30/models/referral_entity.dart';
import 'package:app_30/models/regist_num_entity.dart';
import 'package:app_30/models/tgjf_entity.dart';
import 'package:app_30/models/vip_entity.dart';
import 'package:app_30/res/constant.dart';
import 'package:app_30/util/cache_utils.dart';

import 'dio_utils.dart';
import 'http_api.dart';

login() async {
  Map<String, dynamic> map = Map();
  map['user'] = "will111";
  map['password'] = 'will222';

  await DioUtils.instance.requestNetwork<LoadEntity>(
    Method.post,
    HttpApi.denglu,
    params: map,
    onSuccess: (data) {
      setLoadData(data!);
      print('${data.user}');
      print(getLoadData());
    },
    onError: (_, __) {
      print('$_, $__');
    },
  );
}

getviplevel() async {
  Map<String, dynamic> map = Map();
  map['viplevel'] = "1";

  await DioUtils.instance.requestNetwork<VipEntity>(
    Method.post,
    HttpApi.viplevel,
    params: map,
    onSuccess: (data) {
      print('-----------  ${data!.dayje}');
    },
    onError: (_, __) {
      print('$_, $__');
    },
  );
}
// 推荐奖励
searchTjMm() async {
  Map<String, dynamic> map = Map();
  map['user'] = "will111";
  map['mysqlid'] = "1";
  map['type'] = Constant.tjmx;
  map['num'] = "";

  await DioUtils.instance.requestNetwork<List<ReferralEntity>>(
    Method.post,
    HttpApi.chaxun,
    params: map,
    onSuccess: (data) {
      print('-----------  ${data!.length}');
    },
    onError: (_, __) {
      print('$_, $__');
    },
  );
}

//  数据包含换行符 有问题
// 申请结算
fcEran() async {
  Map<String, dynamic> map = Map();
  map['user'] = "will111";
  map['mysqlid'] = "1";
  map['txzh'] = "18364181239@qq";
  map['txxm'] = "ssss";
  map['app'] =  getPlatform();
  map['time'] = "";

  await DioUtils.instance.requestNetwork<String>(
    Method.post,
    HttpApi.tjrfcget,
    params: map,
    onSuccess: (data) {
      print('-----------  ${data}');
    },
    onError: (_, __) {
      print('$_, $__');
    },
  );
}

// Constant.fcjl; 分成记录
// Constant.txjl; 提现记录
searchTxjl(type) async {
  Map<String, dynamic> map = Map();
  map['user'] = "will111";
  map['mysqlid'] = "1";
  // map['type'] = Constant.fcjl;
  map['type'] = type;
  map['num'] = "";

  await DioUtils.instance.requestNetwork<List<DetailEntity>>(
    Method.post,
    HttpApi.chaxun,
    params: map,
    onSuccess: (data) {
      print('-----------  ${data!.length}');
    },
    onError: (_, __) {
      print('$_, $__');
    },
  );
}

searchTgjf() async {
  Map<String, dynamic> map = Map();
  map['user'] = "will111";
  map['mysqlid'] = "1330373";
  map['type'] = Constant.tgjifen;
  map['num'] = "";

  await DioUtils.instance.requestNetwork<TgjfEntity>(
    Method.post,
    HttpApi.chaxun,
    params: map,
    onSuccess: (data) {
      print('-----------  ${data!.user}');
    },
    onError: (_, __) {
      print('$_, $__');
    },
  );
}

searchRegistnum() async {
  Map<String, dynamic> map = Map();
  map['user'] = "will111";
  map['mysqlid'] = "1330373";
  map['type'] = Constant.tjnum;
  map['num'] = "";

  await DioUtils.instance.requestNetwork<RegistNumEntity>(
    Method.post,
    HttpApi.chaxun,
    params: map,
    onSuccess: (data) {
      print('-----------  ${data!.user}');
    },
    onError: (_, __) {
      print('$_, $__');
    },
  );
}

getdwzurl() async {
  Map<String, dynamic> map = Map();
  map['user'] = "will111";
  map['url'] = "https://www.baidu.com";
  map['time'] = "";

  await DioUtils.instance.requestNetwork<String>(
    Method.post,
    HttpApi.getdwzurl,
    params: map,
    onSuccess: (data) {
      print('-----------  ${data}');
    },
    onError: (_, __) {
      print('$_, $__');
    },
  );
}


getFreevip(
  String? user,
  String? mysqlid,
  String? tgjifen,
  String? tgfennum,
  String? tjrnum,
  String? vip,
) async {
  Map<String, dynamic> map = Map();
  map['user'] = "${user}";
  map['mysqlid'] = "${mysqlid}";
  map['tgjifen'] = "${tgjifen}";
  map['tgfennum'] = "${tgfennum}";
  map['tjrnum'] = "${tjrnum}";
  map['vip'] = "${vip}";
  map['time'] = "";

  await DioUtils.instance.requestNetwork<String>(
    Method.post,
    HttpApi.getfreevip,
    params: map,
    onSuccess: (data) {
      print('-----------  ${data}');
    },
    onError: (_, __) {
      print('$_, $__');
    },
  );
}

///  有问题 shu ju bu quan
getImg() async {
  Map<String, dynamic> map = Map();
  map['user'] = "will111";
  map['time'] = "";
  map['app'] =  getPlatform();

  await DioUtils.instance.requestNetwork<ImgEntity>(
    Method.post,
    HttpApi.getimg,
    params: map,
    onSuccess: (data) {
      print('-----------  ${data!.img}');
    },
    onError: (_, __) {
      print('$_, $__');
    },
  );
}

///

